import {
  UPDATE_ADMIN_STATUS
} from './mutations-types'

export default {
  // 更改用户状态信息
  [UPDATE_ADMIN_STATUS](state, admin) {
    // 登录成功
    if (admin) {
      state.currentAdmin = admin
      state.isLogin = true
    } else if (admin === '') {
      // 退出登录，清空 sessionStorage 里的东西
      sessionStorage.setItem('admin', '')
      sessionStorage.setItem('token', '')
      state.currentAdmin = ''
      state.isLogin = false
    }
  },

  getAdminInfo (state, payload) {
    state.adminInfo = payload
  },

  updateAvatar (state, payload) {
    state.adminInfo.avatar = payload
  }
}